﻿using System.IO;
using GameFramework.Diagnostics;
using GameFramework.Extensions;
using GameFramework.GameObjects;
using GameFramework.VisualTests.Content;

namespace GameFramework.VisualTests.Screens
{
    public class AccelerometerLabelTest : Screen
    {
        private AccelerometerLabel accelerometerLabel;

        public AccelerometerLabelTest()
        {
            accelerometerLabel = new AccelerometerLabel(Fonts.Text);
        }

        public override void Update()
        {
            if (IsBackButtonPressed)
            {
                Game.Exit();
            }

            accelerometerLabel.Update();
        }

        public override void Draw()
        {
            accelerometerLabel.Draw();
        }

        public override void ScreenActivated()
        {
            base.ScreenActivated();

            Input.StartAccelerometer();
        }

        public override void ScreenClosing()
        {
            base.ScreenClosing();

            Input.StopAccelerometer();
        }

        public override void Read(BinaryReader reader)
        {
            base.Read(reader);

            accelerometerLabel = reader.ReadObject<AccelerometerLabel>();
        }

        public override void Write(BinaryWriter writer)
        {
            base.Write(writer);

            writer.WriteObject(accelerometerLabel);
        }
    }
}